package com.pan.admin.framework.listener;

import com.pan.admin.cache.init.AbstractInitCache;
import com.pan.admin.cache.init.InitCacheManager;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 *  初始化加载任务
 *
 *  @author Pan
 */
@Component
public class InitTaskListener implements ApplicationListener<ContextRefreshedEvent> {

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        //  初始化缓存
        List<AbstractInitCache> listInitCache = InitCacheManager.getBeans();
        for (AbstractInitCache initCache : listInitCache) {
            initCache.initCache();
        }
    }
}
